package com.iknow.app;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Resources;
import com.iknow.Config;
import com.iknow.IKnow;
import com.iknow.ui.model.IKPageAdapter;
import com.iknow.util.StringUtil;
import com.iknow.util.SystemUtil;
import com.iknow.util.enums.TypefaceEnum;
import java.util.Map;
import java.util.Properties;

public class IKnowSystemConfig
{
  public static final String BOOK_TYPEFACE_ENUM = "com.iknow.framework.util.BOOK_TYPEFACE_ENUM";
  public static final String BOOK_TYPEFACE_INT = "com.iknow.framework.util.BOOK_TYPEFACE_INT";
  public static final String Book_BACKGROUND = "com.iknow.framework.util.background";
  public static final String Book_COLOR = "com.iknow.framework.util.color";
  public static final String Book_LIGHT = "com.iknow.framework.util.light";
  public static final String Book_SIZE = "com.iknow.framework.util.size";
  public static final String Book_SPACE = "com.iknow.framework.util.space";
  public static final String SYS_SOURCETYPE = "com.iknow.framework.util.SYS_SOURCETYPE";
  private Context mContext;
  private Map<String, String> parmCache = null;

  public IKnowSystemConfig(Context paramContext)
  {
    this.mContext = paramContext;
  }

  // ERROR //
  private Properties getSysProperties()
  {
    // Byte code:
    //   0: new 51	java/util/Properties
    //   3: dup
    //   4: invokespecial 52	java/util/Properties:<init>	()V
    //   7: astore_1
    //   8: aconst_null
    //   9: astore_2
    //   10: new 54	java/io/File
    //   13: dup
    //   14: invokestatic 60	com/iknow/util/SystemUtil:getSystemConfigFilePath	()Ljava/lang/String;
    //   17: invokespecial 63	java/io/File:<init>	(Ljava/lang/String;)V
    //   20: astore_3
    //   21: aload_3
    //   22: invokevirtual 67	java/io/File:exists	()Z
    //   25: ifne +16 -> 41
    //   28: aload_3
    //   29: invokevirtual 71	java/io/File:getParentFile	()Ljava/io/File;
    //   32: invokevirtual 74	java/io/File:mkdirs	()Z
    //   35: pop
    //   36: aload_3
    //   37: invokevirtual 77	java/io/File:createNewFile	()Z
    //   40: pop
    //   41: new 79	java/io/FileInputStream
    //   44: dup
    //   45: aload_3
    //   46: invokespecial 82	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   49: astore 9
    //   51: aload_1
    //   52: aload 9
    //   54: invokevirtual 86	java/util/Properties:load	(Ljava/io/InputStream;)V
    //   57: aload 9
    //   59: ifnull +72 -> 131
    //   62: aload 9
    //   64: invokevirtual 89	java/io/FileInputStream:close	()V
    //   67: aload_1
    //   68: areturn
    //   69: astore 6
    //   71: aload 6
    //   73: astore 7
    //   75: aload 7
    //   77: invokevirtual 92	java/lang/Exception:printStackTrace	()V
    //   80: aload_2
    //   81: ifnull -14 -> 67
    //   84: aload_2
    //   85: invokevirtual 89	java/io/FileInputStream:close	()V
    //   88: goto -21 -> 67
    //   91: astore 8
    //   93: aload 8
    //   95: invokevirtual 93	java/io/IOException:printStackTrace	()V
    //   98: goto -31 -> 67
    //   101: astore 4
    //   103: aload_2
    //   104: ifnull +7 -> 111
    //   107: aload_2
    //   108: invokevirtual 89	java/io/FileInputStream:close	()V
    //   111: aload 4
    //   113: athrow
    //   114: astore 5
    //   116: aload 5
    //   118: invokevirtual 93	java/io/IOException:printStackTrace	()V
    //   121: goto -10 -> 111
    //   124: astore 11
    //   126: aload 11
    //   128: invokevirtual 93	java/io/IOException:printStackTrace	()V
    //   131: goto -64 -> 67
    //   134: astore 4
    //   136: aload 9
    //   138: astore_2
    //   139: goto -36 -> 103
    //   142: astore 10
    //   144: aload 10
    //   146: astore 7
    //   148: aload 9
    //   150: astore_2
    //   151: goto -76 -> 75
    //
    // Exception table:
    //   from	to	target	type
    //   10	51	69	java/lang/Exception
    //   84	88	91	java/io/IOException
    //   10	51	101	finally
    //   75	80	101	finally
    //   107	111	114	java/io/IOException
    //   62	67	124	java/io/IOException
    //   51	57	134	finally
    //   51	57	142	java/lang/Exception
  }

  // ERROR //
  private void saveSysProperties(Properties paramProperties)
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_2
    //   2: new 54	java/io/File
    //   5: dup
    //   6: invokestatic 60	com/iknow/util/SystemUtil:getSystemConfigFilePath	()Ljava/lang/String;
    //   9: invokespecial 63	java/io/File:<init>	(Ljava/lang/String;)V
    //   12: astore_3
    //   13: aload_3
    //   14: invokevirtual 67	java/io/File:exists	()Z
    //   17: ifne +16 -> 33
    //   20: aload_3
    //   21: invokevirtual 71	java/io/File:getParentFile	()Ljava/io/File;
    //   24: invokevirtual 74	java/io/File:mkdirs	()Z
    //   27: pop
    //   28: aload_3
    //   29: invokevirtual 77	java/io/File:createNewFile	()Z
    //   32: pop
    //   33: new 97	java/io/PrintStream
    //   36: dup
    //   37: aload_3
    //   38: invokespecial 98	java/io/PrintStream:<init>	(Ljava/io/File;)V
    //   41: astore 7
    //   43: aload_1
    //   44: aload 7
    //   46: invokevirtual 102	java/util/Properties:list	(Ljava/io/PrintStream;)V
    //   49: aload 7
    //   51: ifnull +8 -> 59
    //   54: aload 7
    //   56: invokevirtual 103	java/io/PrintStream:close	()V
    //   59: return
    //   60: astore 5
    //   62: aload 5
    //   64: astore 6
    //   66: aload 6
    //   68: invokevirtual 92	java/lang/Exception:printStackTrace	()V
    //   71: aload_2
    //   72: ifnull -13 -> 59
    //   75: aload_2
    //   76: invokevirtual 103	java/io/PrintStream:close	()V
    //   79: goto -20 -> 59
    //   82: astore 4
    //   84: aload_2
    //   85: ifnull +7 -> 92
    //   88: aload_2
    //   89: invokevirtual 103	java/io/PrintStream:close	()V
    //   92: aload 4
    //   94: athrow
    //   95: astore 4
    //   97: aload 7
    //   99: astore_2
    //   100: goto -16 -> 84
    //   103: astore 8
    //   105: aload 8
    //   107: astore 6
    //   109: aload 7
    //   111: astore_2
    //   112: goto -46 -> 66
    //
    // Exception table:
    //   from	to	target	type
    //   2	43	60	java/lang/Exception
    //   2	43	82	finally
    //   66	71	82	finally
    //   43	49	95	finally
    //   43	49	103	java/lang/Exception
  }

  public void Destroy()
  {
    this.parmCache.clear();
  }

  public int getBook_BackGround()
  {
    int j;
    int i = getInt("com.iknow.framework.util.background");
    Resources localResources = IKnow.mContext.getResources();
    if (i == 0)
      j = 2131165210;
    while (true)
    {
      return localResources.getColor(j);
      j = i;
    }
  }

  public int getBook_BackGroundId()
  {
    return getInt("com.iknow.framework.util.background");
  }

  public float getBook_Light()
  {
    float f2;
    float f1 = getFloat("com.iknow.framework.util.light");
    if (f1 == 0F)
      f2 = 0.30000001192092896F;
    while (true)
    {
      return f2;
      f2 = f1;
    }
  }

  public float getBook_Spacing()
  {
    float f2;
    float f1 = getFloat("com.iknow.framework.util.space");
    if (f1 == 0F)
      f2 = 1F;
    while (true)
    {
      return f2;
      f2 = f1;
    }
  }

  public int getBook_TextColor()
  {
    int j;
    int i = getInt("com.iknow.framework.util.color");
    Resources localResources = IKnow.mContext.getResources();
    if (i == 0)
      j = 2131165184;
    while (true)
    {
      return localResources.getColor(j);
      j = i;
    }
  }

  public int getBook_TextColorId()
  {
    return getInt("com.iknow.framework.util.color");
  }

  public int getBook_TextSize()
  {
    int j;
    int i = getInt("com.iknow.framework.util.size");
    if (SystemUtil.getDisplayHeight() >= 800)
      if (i == 0)
        j = 26;
    while (true)
    {
      while (true)
      {
        while (true)
        {
          return j;
          j = i;
        }
        if (i != 0)
          break;
        j = 16;
      }
      j = i;
    }
  }

  public TypefaceEnum getBook_Typeface_Enum()
  {
    return TypefaceEnum.getEnum(getInt("com.iknow.framework.util.BOOK_TYPEFACE_ENUM"));
  }

  public int getBook_Typeface_Int()
  {
    return getInt("com.iknow.framework.util.BOOK_TYPEFACE_INT");
  }

  public boolean getBoolean(String paramString)
  {
    int i;
    if (getInt(paramString) == 1)
      i = 1;
    while (true)
    {
      return i;
      i = 0;
    }
  }

  public float getFloat(String paramString)
  {
    float f;
    String str = getString(paramString);
    if (StringUtil.isEmpty(str))
      f = 0F;
    while (true)
    {
      return f;
      f = Float.valueOf(str).floatValue();
    }
  }

  public int getInt(String paramString)
  {
    int i;
    String str = getString(paramString);
    if (StringUtil.isEmpty(str))
      i = 0;
    while (true)
    {
      return i;
      i = Integer.parseInt(str);
    }
  }

  public long getLong(String paramString)
  {
    long l;
    String str = getString(paramString);
    if (StringUtil.isEmpty(str))
      l = 0L;
    while (true)
    {
      return l;
      l = Long.valueOf(str).longValue();
    }
  }

  public String getPhoneNumber()
  {
    String str = getString("PhoneNumber");
    if (StringUtil.isEmpty(str))
      str = "-1";
    return str;
  }

  public String getString(String paramString)
  {
    return IKnow.mPref.getString(paramString, "");
  }

  public String getStringFromOldDB(String paramString)
  {
    return "";
  }

  public String getSysSourceType()
  {
    return getString("com.iknow.framework.util.SYS_SOURCETYPE");
  }

  public void refSystemSourceType()
  {
    Properties localProperties = getSysProperties();
    if (localProperties == null);
    while (true)
    {
      String str1;
      IKnowSystemConfig localIKnowSystemConfig;
      do
        while (true)
        {
          return;
          str1 = localProperties.getProperty("source.type");
          localIKnowSystemConfig = IKnow.mSystemConfig;
          if (!(StringUtil.isEmpty(str1)))
            break;
          String str2 = getSysSourceType();
          if (StringUtil.isEmpty(str2))
          {
            str2 = Config.DefultSourceType.value;
            localIKnowSystemConfig.setString("com.iknow.framework.util.SYS_SOURCETYPE", str2);
          }
          localProperties.put("source.type", str2);
          saveSysProperties(localProperties);
        }
      while (StringUtil.equalsString(str1, getSysSourceType()));
      localIKnowSystemConfig.setString("com.iknow.framework.util.SYS_SOURCETYPE", str1);
    }
  }

  public void saveBook_Light(float paramFloat)
  {
    setFloat("com.iknow.framework.util.light", Float.valueOf(paramFloat));
  }

  public void saveBook_TextSize()
  {
    setInt("com.iknow.framework.util.size", IKnow.getTextSize());
  }

  public void setBook_BackGroundRes(Context paramContext, int paramInt)
  {
    setInt("com.iknow.framework.util.background", paramInt);
  }

  public void setBook_Spacing(float paramFloat)
  {
    setFloat("com.iknow.framework.util.space", Float.valueOf(paramFloat));
  }

  public void setBook_TextColorRes(IKPageAdapter paramIKPageAdapter, int paramInt)
  {
    setInt("com.iknow.framework.util.color", paramInt);
    paramIKPageAdapter.notifyDataSetChanged();
  }

  public void setBook_Typeface_Enum(TypefaceEnum paramTypefaceEnum)
  {
    setInt("com.iknow.framework.util.BOOK_TYPEFACE_ENUM", paramTypefaceEnum.id);
  }

  public void setBook_Typeface_Int(int paramInt)
  {
    setInt("com.iknow.framework.util.BOOK_TYPEFACE_INT", paramInt);
  }

  public void setBoolean(String paramString, boolean paramBoolean)
  {
    int i;
    if (paramBoolean)
      i = 1;
    while (true)
    {
      setInt(paramString, i);
      return;
      i = 0;
    }
  }

  public void setFloat(String paramString, Float paramFloat)
  {
    setString(paramString, String.valueOf(paramFloat));
  }

  public void setInt(String paramString, int paramInt)
  {
    setString(paramString, String.valueOf(paramInt));
  }

  public void setLong(String paramString, long paramLong)
  {
    setString(paramString, String.valueOf(paramLong));
  }

  public void setString(String paramString1, String paramString2)
  {
    SharedPreferences.Editor localEditor = IKnow.mPref.edit();
    localEditor.putString(paramString1, paramString2);
    localEditor.commit();
  }
}